//
//  HomeBannerCell.m
//  Cat
//
//  Created by lushitong on 2018/12/17.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "HomeBannerCell.h"
#import "FLImageView.h"
#import "WebViewController.h"
#import "HomePriorityInfo.h"

@interface HomeBannerCell() <FLImageViewDelegate>
@property (nonatomic, strong) FLImageView *bannerView;
@end

@implementation HomeBannerCell

+ (CGSize)getHomeBannerSize {
	return CGSizeMake(ScreenWidth - kQKFitModuleDecimal(22.0) * 2, kQKFitModuleDecimal(145.0));
}

- (void)setModel:(BannersModel *)model {
	_model = model;
	self.bannerView.urlNotHaveCircle = model.imgURL;
}

- (instancetype)initWithFrame:(CGRect)frame {
	if (self = [super initWithFrame:frame]) {
		self.userInteractionEnabled = YES;
		[self loadSubviews];
	}
	return self;
}

- (void)loadSubviews {
	[self.contentView addSubview:self.bannerView];
	[self.bannerView  mas_makeConstraints:^(MASConstraintMaker *make) {
		make.size.equalTo([HomeBannerCell getHomeBannerSize]);
		make.top.equalTo(self.contentView.mas_top).offset(kQKFitModuleDecimal(5.0));
		make.centerY.equalTo(self.contentView.mas_centerY);
	}];
}

#pragma mark----- lazy init -----

- (FLImageView *)bannerView {
	if (!_bannerView) {
		_bannerView = [[FLImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, [HomeBannerCell getHomeBannerSize].width, [HomeBannerCell getHomeBannerSize].height)];
		_bannerView.delegate = self;
		_bannerView.userInteractionEnabled = YES;
		_bannerView.layer.cornerRadius = kQKFitModuleDecimal(5.0);
		_bannerView.layer.masksToBounds = YES;
	}
	return _bannerView;
}

- (void)clickImageView:(FLImageView *)headView {
	WebViewController *webVc = [[WebViewController alloc] init];
	webVc.URL = self.model.targetURL;
	[self.currentNavigationController pushViewController:webVc animated:YES];
}

@end
